package com.example.spring_secutity.service.impl;

import com.example.spring_secutity.entity.Right;
import com.example.spring_secutity.entity.RoleRight;
import com.example.spring_secutity.mapper.RightMapper;
import com.example.spring_secutity.service.IRightService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zz
 * @since 2024-07-11
 */
@Service
public class RightServiceImpl extends ServiceImpl<RightMapper, Right> implements IRightService {

    @Resource
    RightMapper rightMapper;

    @Override
    public List<Right> getPermissinsByRoleId(Integer roleId) {
        List<Right> rightList = rightMapper.selectJoinList(Right.class
                , new MPJLambdaWrapper<Right>()
                        .selectAll(Right.class)
                        .innerJoin(RoleRight.class,RoleRight::getRfRightCode,Right::getRightCode)
                        .eq(RoleRight::getRfRoleId,roleId)
//                        .eq(new RoleRight().getRfRoleId(),roleId)
        );

        return rightList;
    }
}
